<?php
/*
*类学习 17-25
*/

//第八讲 类中多态的应用 instanceof




/*
//第七讲 类中接口中的应用
interface demo{
	const NAME = "名字";
	function Fun1();
	function Fun2();
}
class MyPc implements demo{
	function Fun1(){
	
	}
	function Fun2(){
		if(3>2):
			echo "if中不用括号改用冒号和endif结束";
		endif;
	}
}
$p = new MyPc();
$p->Fun2();
*/


/*
//第六讲 类中常用的关键字 fianl self static const
class MyPc{
	static $name = "我的电脑";
	function power(){
		echo $this->name.",电脑开机中。。。。";
	}
}
class My extends MyPc{
	function power(){
		echo MyPc::power()."*****";
	}
}
//$p = new My();
//$p->power();
echo MyPc::$name;
*/


//第五讲 类的抽象方法和类  提供一个规范
/*
abstract class C1{
	abstract function fun1();
	function test(){
		echo "test1";
	}
}
class C2 extends C1{
	function fun1(){
		echo "test";
	}
}
$p = new C2();
echo $p->test();
*/

//第四讲 类的继承和应用,重载  你类（基类），子类（派生类）  单一继承
/*
class Root{
	function print1(){
		return "Root print1<br />";
	}
}
class Son extends Root{
	function print1(){
		return Root::print1()."Son print2<br />";
	}
}
$pc1 = new Son();
echo $pc1->print1();
*/

/*
//第三讲 类的封装和应用 public protected private  __set()  __get()
class MyPc{
	private $name;
	private $type;
	
	function __construct($name = '',$type = ''){
		return $this->name = $name;
	}
	private function power(){
		return $this->name."打开电源，正在开机";
	}
	public function ok(){
		return $this->power()."。。。开机成功了";
	}
	function __get($name){
		return $this->name."====";
	}
	function __set($n,$v){
		$this->$n = $v;
	}
}
$pc1 = new MyPc("我的电脑","台式");
$pc1->name = "你的电脑";
echo $pc1->name;
$pc1 -> name = "aaaa";
echo $pc1->type;
*/


//第二讲
/*
class MyPc{
	public $name;
	public $type;
	
	//初始化操作 __construct
	function __construct($name="",$type=""){
		$this->name = $name;
		$this->type = $type;
	}
	//析构函数 规则：后进先出
	function __destruct(){
		echo "<br />=====".$this->name."<br />";
	}	
	function vod(){
		return $this->name.$this->type.",播放电影";
	}
	function game(){
		return $this->vod().",玩游戏";
	}
	function intelnet(){
		return $this->name.",上网";
	}
}
$pc1 = new MyPc("家用电脑","台式机");
$pc2 = new MyPc("公司电脑");
echo $pc1->vod()."<br />";
//$pc1 = null;
echo $pc2->game();
*/

/*第一讲
class MyPc{
	public $name;
	function vod(){
		echo "PHP学习";
	}
}
$pc1 = new MyPc();//定义对象1
$pc1->vod();
$pc1->name = "<br />PHP";
echo $pc1->name;
*/

?>